package com.manpower.view;

import com.manpower.ui.R;

import android.content.Context;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.ImageView;

public class ButtonBack extends ImageView{
	private boolean isPressed = false;
	public ButtonBack(Context context, AttributeSet attrs) {
		super(context, attrs);
	}
	
	@Override
	public void draw(Canvas canvas) {
		super.draw(canvas);
		if(isPressed)
			this.setImageDrawable(getResources().getDrawable(R.drawable.ic_btnback_over));
		else
			this.setImageDrawable(getResources().getDrawable(R.drawable.ic_btnback_default));
	}
	
	@Override
	public boolean onTouchEvent(MotionEvent event) {
		super.onTouchEvent(event);
		if (isEnabled()) {
			if (event.getAction() == MotionEvent.ACTION_DOWN
					|| event.getAction() == MotionEvent.ACTION_MOVE)
				isPressed = true;
			else
				isPressed = false;
			postInvalidate();
		}
		return true;
	}
}
